package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/admin/setmeal")
@Api(tags = "套餐管理相关接口")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    @PostMapping
    @ApiOperation("新增套餐")
    public Result addSetmeal(@RequestBody SetmealDTO setmealDTO){
        return setmealService.addSetmeal(setmealDTO);
    }

    @GetMapping("/page")
    @ApiOperation("套餐分页查询")
    public Result querySetmealByPage(SetmealPageQueryDTO setmealPageQueryDTO){
        return setmealService.querySetmealByPage(setmealPageQueryDTO);
    }

    @DeleteMapping
    @ApiOperation("删除套餐")
    public Result batchDeleteSetmealsByids(@RequestParam List<Long> ids){
        return setmealService.batchDeleteSetmealsByids(ids);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询套餐")
    public Result querySetmealById(@PathVariable("id") Integer id){
        return setmealService.querySetmealById(id);
    }

    @PutMapping
    @ApiOperation("修改套餐")
    public Result updateSetmeal(@RequestBody SetmealDTO setmealDTO){
        return setmealService.updateSetmeal(setmealDTO);
    }

    @PostMapping("/status/{status}")
    @ApiOperation("启售停售套餐")
    public Result updateStatus(@PathVariable Integer status, Long id){
        return setmealService.updateStatus(status,id);
    }
}
